﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers.world {
    import flash.events.*;
    import flash.geom.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.models.world.vos.areas.*;
    import net.wooga.pets.interfaces.*;
    import net.wooga.pets.models.world.vos.actors.machines.*;
    import net.wooga.pets.constants.*;
    import net.wooga.pets.models.world.*;

    public class CreateBabyCommand extends CreateActorCommand {

		[Inject]
        public var world:WorldModel;
		[Inject]
        public var userModel:UserModel;

        override public function execute():void{
            var _local1:IBaby = (worldFactory.createActor(event.info) as IBaby);
            this.setActor(_local1, EventConstants.CREATE_BABY_VIEW);
            var _local2:IRoom = (worldModel.getRoomById(_local1.roomId) as IRoom);
            _local2.handleBaby(_local1, this.userModel.isVisitFriendsMode());
        }
        override protected function setActor(_arg1:IActing, _arg2:String):void{
            if (!worldModel.getActor(_arg1.id)){
                worldModel.addActor(_arg1);
            };
            dispatch(new InfoEvent(_arg2, null, _arg1));
            var _local3:String = this.world.getRoomIdsOfType(GameConstants.TYPE_KINDERGARTEN)[0];
            var _local4:RoomVO = (worldModel.getRoomById(_arg1.roomId) as RoomVO);
            var _local5:IRoom = (this.world.getRoomById(_local3) as IRoom);
            var _local6:KindergartenMachineVO = (_local5.machine as KindergartenMachineVO);
            var _local7:int = _local6.getFreePos;
            var _local8:Point = _local4.getTargetPositionOf(("baby_" + _local7));
            var _local9:Point = roomSlotsModel.getSlotById(_local4.slotId).position;
            var _local10:Point = new Point((_local9.x + _local8.x), (_local9.y + _local8.y));
            dispatch(new InfoEvent(EventConstants.SET_TO_POSITION, _arg1.id, _local10));
            dispatch(new Event(EventConstants.UPDATE_MORE_PETS_ARROW));
        }

    }
}//package net.wooga.pets.controllers.world 
